package BoBai;

import java.util.Random;
import java.util.ArrayList;



public class BoBais {

	private ArrayList<LaBai> cards;

	public BoBais()
	   {
	       cards = new ArrayList<LaBai>();
	       int index_1, index_2;
	       Random generator = new Random();
	       LaBai temp;

	       for (short a=0; a<=3; a++)
	       {
	           for (short b=0; b<=12; b++)
	            {
	              cards.add( new LaBai(a,b,tenBai(a, b)) );
	            }
	       }

	       int size = cards.size() -1;

	       for (short i=0; i<100; i++)
	       {
	           index_1 = generator.nextInt( size );
	           index_2 = generator.nextInt( size );

	           temp = (LaBai) cards.get( index_2 );
	           cards.set( index_2 , cards.get( index_1 ) );
	           cards.set( index_1, temp );
	       }
	   }

	   public LaBai layMotLaBai()
	   {       
	       return cards.remove( cards.size()-1 );
	   }

	   public int layTongSoLaBai()
	   {
	       return cards.size();
	       //we could use this method when making 
	       //a complete poker game to see if we needed a new deck
	   }
	   
	   public String tenBai(short a, short b)
	   {
		   String kq,name1,name2;
		   kq = name1 = name2 = null;
		   // gan ten dau
		   switch(a)
		   {
		   case 0:
			   name1 = "c";
			   break;
		   case 1:
			   name1 = "d";
			   break;
		   case 2:
			   name1 = "h";
			   break;
		   case 3:
			   name1 = "s";
			   break;
		   default:
			   break;
		   }
		   
		   //gan ten cuoi
		   
		   switch(b)
		   {
		   case 0:
			   name2 = "1";
			   break;
		   case 1:
			   name2 = "2";
			   break;
		   case 2:
			   name2 = "3";
			   break;
		   case 3:
			   name2 = "4";
			   break;
		   case 4:
			   name2 = "5";
			   break;
		   case 5:
			   name2 = "6";
			   break;
		   case 6:
			   name2 = "7";
			   break;
		   case 7:
			   name2 = "8";
			   break;
		   case 8:
			   name2 = "9";
			   break;
		   case 9:
			   name2 = "10";
			   break;
		   case 10:
			   name2 = "j";
			   break;
		   case 11:
			   name2 = "k";
			   break;
		   case 12:
			   name2 = "q";
			   break;
		   default:
			   break;
		   }
		   if(name1 != null && name2 != null)
		   {
			   kq = name1+name2+".png";
		   }
		   return kq;
	   }
}
